package cn.fuxi2022.accounts.menu.controller;

import cn.fuxi2022.accounts.menu.service.WeChatMenuService;
import cn.fuxi2022.model.resp.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 调整 微信菜单
 */
@RestController
@RequestMapping("weChatMenu")
public class WeChatMenuController {

    @Autowired
    private WeChatMenuService weChatMenuService;

    /**
     * 请求微信服务器，获取 AccessToken
     * 是公众号的全局唯一接口调用凭据，公众号调用各接口时都需使用access_token
     * @return AccessToken
     */
    @GetMapping("/getAccessToken")
    public R getAccessToken(){
        return R.ok(weChatMenuService.getAccessToken());
    }

    /**
     * 通知微信，同步微信菜单
     */
    @GetMapping("/syncMenu")
    public R syncMenu(){
        weChatMenuService.syncMenu();
        return R.ok();
    }

    /**
     * 通知微信，删除微信菜单
     */
    @GetMapping("/removeMenu")
    public R removeMenu(){
        weChatMenuService.removeMenu();
        return R.ok();
    }
}
